/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.eclass.servlet.front;

import cn.eclass.bean.api.ISchoolLinkBean;
import cn.eclass.entity.SchoolLinkEntity;
import cn.eclass.servlet.ActionFace;
import cn.eclass.utils.BeanFactory;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;

/**
 *
 * @author fortruth
 */
public class Schoollink extends ActionFace {

    ISchoolLinkBean bean = BeanFactory.factory.getSchoolLinkBean();

    @Override
    public void doIndex() {
        int categoryId = Integer.valueOf(request.getParameter("catId"));
        int pageId = Integer.valueOf(request.getParameter("pageId"));
        List<SchoolLinkEntity> schoolLinks = bean.getSchoolLinkByCat(categoryId, 12, pageId);//12 will be stored in config file
        int schoolLinkCount = bean.getMaxItemByCat(categoryId);
        request.setAttribute("schoollinks", schoolLinks);
        request.setAttribute("schoolLinkCount", schoolLinkCount);
        try {
            request.getRequestDispatcher(view).forward(request, response);
        } catch (ServletException ex) {
            Logger.getLogger(Schoollink.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Schoollink.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
}
